package com.mezz.bones.im.sdk.demo;

import com.alibaba.fastjson.JSONObject;
import com.mezz.bones.im.sdk.domain.request.*;
import com.mezz.bones.im.sdk.domain.base.BaseResponse;
import com.mezz.bones.im.sdk.client.LaicuiImClient;
import com.mezz.bones.im.sdk.domain.response.ConversationRecordRes;
import com.mezz.bones.im.sdk.domain.response.MessageUnReadCountResponse;
import com.mezz.bones.im.sdk.domain.response.StringResponse;

/**
 * @Author: zhuang
 * @Date: 2025/5/9 9:45
 * @Description: TODO
 * @Version: 1.0
 **/

public class LaicuiImClientTest {

    private static String gateway = "http://172.10.0.155:18085";
    private static String appId = "dev-134595222021";
    private static String appSecret = "dev-0d427b5c01d438e9a1666e72345316ab752ac409567dde941b297fa264453314182";

    public static void main(String[] args) {
//        testUserSign();
//        testUserImport();
//        testUserUpdate();
//        testUserDelete();
//        testUserRemarkSetting();
//        testUserRemarkClear();
//        testConversationUnreadCount();
//        testConversationRecord();
        testPrivateMessageCreate();
    }

    private static void testPrivateMessageCreate() {

        LaicuiImClient imClient = new LaicuiImClient(gateway, appId, appSecret);

        PrivateMessageCreateRequest request = new PrivateMessageCreateRequest();

        request.setUserId("3");
        request.setPeerId("4");
        request.setMsgType(0);
        request.setSync2Peer(1);
        request.setPush2User(0);
        request.setContentType("text");
        request.setContent(JSONObject.parseObject("{\"text\":\"hello\"}"));
        request.setMsgExtra(new JSONObject());

        BaseResponse<ConversationRecordRes> execute = imClient.execute(request);

        System.out.println(execute.getData());
    }

    private static void testConversationRecord() {

        LaicuiImClient imClient = new LaicuiImClient(gateway, appId, appSecret);

        ConversationRecordReq request = new ConversationRecordReq();
        request.setUserId("1");

        BaseResponse<ConversationRecordRes> execute = imClient.execute(request);

        System.out.println(execute.getData());
    }

    private static void testConversationUnreadCount() {

        LaicuiImClient imClient = new LaicuiImClient(gateway, appId, appSecret);
        MessageUnReadCountRequest request = new MessageUnReadCountRequest();
        request.setUserId("2");
        BaseResponse<MessageUnReadCountResponse> execute = imClient.execute(request);
        System.out.println(execute.getData());
    }

    private static void testUserRemarkClear() {

        LaicuiImClient imClient = new LaicuiImClient(gateway, appId, appSecret);

        UserRemarkClearRequest request = new UserRemarkClearRequest();
        request.setUserId("1");
        request.setPeerId("2");
        BaseResponse execute = imClient.execute(request);
        System.out.println(execute.getData());
    }

    private static void testUserRemarkSetting() {

        LaicuiImClient imClient = new LaicuiImClient(gateway, appId, appSecret);

        UserRemarkSettingRequest request = new UserRemarkSettingRequest();
        request.setUserId("1");
        request.setPeerId("2");
        request.setRemarkName("2222222-1");

        BaseResponse<StringResponse> execute = imClient.execute(request);
        System.out.println(execute.getData());
    }

    private static void testUserDelete() {

        LaicuiImClient imClient = new LaicuiImClient(gateway, appId, appSecret);
        UserDeleteRequest request = new UserDeleteRequest();
        request.setUserId("4444445");
        BaseResponse<StringResponse> execute = imClient.execute(request);
        System.out.println(execute.getData());
    }

    private static void testUserUpdate() {

        LaicuiImClient imClient = new LaicuiImClient(gateway, appId, appSecret);
        UserUpdateRequest request = new UserUpdateRequest();
        request.setUserId("4444445");
        request.setProfile("33333");
        request.setAvatar("3333");
        request.setNickname("3333");
        BaseResponse<StringResponse> execute = imClient.execute(request);
        execute.getData();
    }

    private static void testUserImport() {

        LaicuiImClient imClient = new LaicuiImClient(gateway, appId, appSecret);
        UserImportRequest request = new UserImportRequest();
        request.setUserId("4444445");
        request.setUserType("srm");
        request.setProfile("dd");
        request.setAvatar("httpp");
        request.setNickname("zhuang");
        BaseResponse<StringResponse> execute = imClient.execute(request);
        execute.getData();
    }
}
